﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using aerowan.server.Network;
using aerowan.server.Database;
using aerowan.common;

namespace aerowan.server
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("This is the AeroWAN Server v.0.1");
            Console.WriteLine(" ");

            PilotLayer.Instance.GetHashCode();

            while (true)
            {
                Console.WriteLine(" ");
                Console.Write("# ");
                string cmd = Console.ReadLine();
                if (cmd == "exit")
                {
                    return;
                }
                else if (cmd.StartsWith(".add"))
                {
                    string[] splitted = cmd.Split(new char[] { ' ' });
                    // .add Christophe Delondre poipoi
                    if (splitted.Length != 4) Console.WriteLine("Invalid parameters.");
                    else
                    {
                        Console.WriteLine("Creating account for " + splitted[2] + ", " + splitted[1]);
                        int id = AccountsDAO.Insert(splitted[1], splitted[2], Utility.PasswordHash(splitted[3]));
                        Console.WriteLine("Account ID " + id + " created.");
                    }
                }
                else
                {
                    Console.WriteLine("Command => " + cmd);
                    Console.WriteLine(" ");
                }
            }
        }
    }
}
